﻿namespace NetRosApp.Klijenti
{
    public partial class BaseTraziView : Infrastructure.Interface.Base.BaseViews.BaseTraziView, IBaseTraziView
    {
        //bool NotModal = true;

        //ItemClickEventHandler _onIzvjestaj;
        //ItemClickEventHandler _onNovi;
        //ItemClickEventHandler _onTrazi;
        //ItemClickEventHandler _onClear;
        //ItemClickEventHandler _onUgasi;
        //String _title = "Genericki trazi";
        //String _description = "Genericki trazi Description";


        //[Category("SmartPartInfo")]
        //public String Title
        //{
        //    set { _title = value; }
        //    get { return _title; }
        //}

        //[Category("SmartPartInfo")]
        //public String Description
        //{
        //    set { _description = value; }
        //    get { return _description; }
        //}

        //[Category("BarGumbi"), Description("Na pritisak gumba")]
        //public event DevExpress.XtraBars.ItemClickEventHandler OnIzvjestaj
        //{
        //    add
        //    {
        //        _onIzvjestaj += new DevExpress.XtraBars.ItemClickEventHandler(value);
        //        barButtonItem1.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(value);
        //    }
        //    remove
        //    {
        //        _onIzvjestaj -= value;
        //        barButtonItem1.ItemClick -= value;
        //    }
        //}
        //[Category("BarGumbi"), Description("Na pritisak gumba")]
        //public event DevExpress.XtraBars.ItemClickEventHandler OnNovi
        //{
        //    add
        //    {
        //        _onNovi += new DevExpress.XtraBars.ItemClickEventHandler(value);
        //        barButtonItem2.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(value);
        //    }
        //    remove
        //    {
        //        barButtonItem2.ItemClick -= value;
        //        _onNovi -= value;
        //    }
        //}
        //[Category("BarGumbi"), Description("Na pritisak gumba")]
        //public event DevExpress.XtraBars.ItemClickEventHandler OnTrazi
        //{
        //    add
        //    {
        //        _onTrazi += new DevExpress.XtraBars.ItemClickEventHandler(value);
        //        barButtonItem3.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(value);
        //    }
        //    remove
        //    {
        //        barButtonItem3.ItemClick -= value;
        //        _onTrazi -= value;
        //    }
        //}
        //[Category("BarGumbi"), Description("Na pritisak gumba")]
        //public event DevExpress.XtraBars.ItemClickEventHandler OnClear
        //{
        //    add
        //    {
        //        _onClear += new DevExpress.XtraBars.ItemClickEventHandler(value);
        //        barButtonItem4.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(value);
        //    }
        //    remove
        //    {
        //        barButtonItem4.ItemClick -= value;
        //        _onClear -= value;
        //    }
        //}
        //[Category("BarGumbi"), Description("Na pritisak gumba")]
        //public event DevExpress.XtraBars.ItemClickEventHandler OnUgasi
        //{
        //    add
        //    {
        //        _onUgasi += new DevExpress.XtraBars.ItemClickEventHandler(value);
        //        barButtonItem5.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(value);
        //    }
        //    remove
        //    {
        //        barButtonItem5.ItemClick -= value;
        //        _onUgasi -= value;
        //    }
        //}
            



        //public BaseTraziView()
        //{
        //  //  base.InitializeComponent();
        //    InitializeComponent();

        //}



        //protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        //{
        //    //const int WM_KEYDOWN = 0x100;
        //    //const int WM_SYSKEYDOWN = 0x104;

        //    //if (msg.Msg == WM_KEYDOWN || msg.Msg == WM_SYSKEYDOWN)
        //    //{
        //    //    switch (keyData)
        //    //    {
        //    //        case Keys.F5:
        //    //            if (NotModal & _onIzvjestaj != null)
        //    //            {
        //    //                _onIzvjestaj.Invoke(this, new ItemClickEventArgs(barButtonItem1, null));
        //    //            }
        //    //            break;
        //    //        case Keys.F6:
        //    //            if (_onNovi != null)
        //    //            {
        //    //                _onNovi.Invoke(this, new ItemClickEventArgs(barButtonItem2, null));
        //    //            }
        //    //            break;
        //    //        case Keys.F8:
        //    //            if (_onTrazi != null)
        //    //            {
        //    //                _onTrazi.Invoke(this, new ItemClickEventArgs(barButtonItem3, null));
        //    //            }
        //    //            break;

        //    //        case Keys.F9:
        //    //            if (_onClear != null)
        //    //            {
        //    //                _onClear.Invoke(this, new ItemClickEventArgs(barButtonItem4, null));
        //    //            }
        //    //            break;

        //    //        case Keys.F12:
        //    //            if (_onUgasi != null)
        //    //            {
        //    //                _onUgasi.Invoke(this, new ItemClickEventArgs(barButtonItem5, null));
        //    //            }
        //    //            break;

        //    //        case  Keys.Control | Keys.W:

        //    //            Type t = this.GetType();
        //    //            MemberInfo[] members = t.GetMembers(BindingFlags.NonPublic | BindingFlags.Public |
        //    //            BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.Instance);
        //    //            foreach (MemberInfo member in members)
        //    //            {
        //    //                if (member.MemberType == MemberTypes.Field)
        //    //                {
        //    //                    FieldInfo fi = t.GetField(member.Name,
        //    //                    BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
        //    //                    if (fi.FieldType == typeof(DevExpress.XtraLayout.LayoutControlGroup))
        //    //                    {
        //    //                        DevExpress.XtraLayout.LayoutControlGroup tes = (fi.GetValue(this) as DevExpress.XtraLayout.LayoutControlGroup);
        //    //                        if (tes.ExpandButtonVisible == true)
        //    //                        {
        //    //                            tes.Expanded = !tes.Expanded;
        //    //                        }
        //    //                    }
        //    //                }
        //    //            }
        //    //            break;

        //    //    }
        //    //}

        //    return base.ProcessCmdKey(ref msg, keyData);
        //}

        //protected internal void CloseAndReleaseView(IBaseTraziPresenter _presenter)
        //{
        //    _presenter.OnCloseView();
        //}

        //protected override void OnLoad(EventArgs e)
        //{
        //    base.OnLoad(e);
        //    Type t = this.GetType();
        //    MemberInfo[] members = t.GetMembers(BindingFlags.NonPublic | BindingFlags.Public |
        //    BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.Instance);
        //    foreach (MemberInfo member in members)
        //    {
        //        if (member.MemberType == MemberTypes.Field)
        //        {
        //            FieldInfo fi = t.GetField(member.Name,
        //            BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
        //            if (fi.FieldType == typeof(DevExpress.XtraLayout.LayoutControl))
        //            {
        //                DevExpress.XtraLayout.LayoutControl tes = (fi.GetValue(this) as DevExpress.XtraLayout.LayoutControl);
        //                tes.AllowCustomizationMenu = false;
        //                tes.OptionsFocus.AllowFocusGroups = false;
        //                tes.OptionsView.HighlightFocusedItem = true;
        //            }
        //        }
        //    }
        //    if ((Parent as Form) != null)
        //    {
        //        NotModal = false;
        //        if ((Parent as Form) != null)
        //        {
        //            barButtonItem1.Enabled = false;
        //            this.Dock = DockStyle.Fill;
        //        }
        //    }
        //}

        // public ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType)
        //{
        //    ISmartPartInfo result = Activator.CreateInstance(smartPartInfoType) as ISmartPartInfo;
        //    result.Title = _title;
        //    result.Description = _description;
        //    return result;
        //} 

     //   public object   SmartPartView {
     //       get { return this; }
     //       }
     //public bool IsFocused()
     //   {
     //       return this.ContainsFocus;
     //   }

        //protected internal void OpenEntityEditor(IBaseTraziPresenter _presenter,object Entity,Type EditorClass)
        //{
        //    if (Entity != null)
        //    {

        //        if (!NotModal)
        //        {

        //            _presenter.OpenEditorNewOrEditinParent(Entity);
        //            try
        //            {
        //                (Parent as Form).Close();
        //            }
        //            catch { }
        //        }
        //        else
        //        {
        //            if (EditorClass != null)
        //            _presenter.OpenEditorNewOrEditinTab(Entity, EditorClass);
        //        }
        //    }
        //}

        //protected internal void OpenEntityEditorNew(IBaseTraziPresenter _presenter, Type EditorClass)
        //{
        //    if (!NotModal)
        //    {
        //        _presenter.OpenEditorNewModal(EditorClass);
        //    }
        //    else
        //    {
        //        _presenter.OpenEditorNewOrEditinTab(null, EditorClass);
        //    }

        //}

        //public void GridView_KeyPress(object sender, KeyPressEventArgs e)
        //{
        //    if (e.KeyChar == (char)Keys.Enter)
        //    {
        //        OpenEditor();
        //    }

        //}

        //public void GridControl_MouseDoubleClick(object sender, MouseEventArgs e)
        //{
        //    DevExpress.XtraGrid.GridControl tmp = sender as DevExpress.XtraGrid.GridControl;
        //    GridHitInfo hi = tmp.FocusedView.CalcHitInfo(new System.Drawing.Point(e.X, e.Y)) as GridHitInfo;
        //    if (hi.InRow)
        //    {
        //        OpenEditor();
        //    }

        //}

        //protected virtual void OpenEditor()
        //{
        //    MessageBox.Show("OpenEditor");
        //}
        
        //protected internal void PostaviStyleConditionZaGrid(GridView gridView1,int Storno)
        //{
        //    PostaviStyleConditionZaGrid(gridView1, Storno, System.Drawing.Color.FromArgb(180, ((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))));
        //}

        //protected internal void PostaviStyleConditionZaGrid(GridView gridView1, int Storno,Color BojaStorno)
        //{
        //    DevExpress.XtraGrid.StyleFormatCondition styleFormatCondition1 = new DevExpress.XtraGrid.StyleFormatCondition();
        //    DevExpress.XtraGrid.StyleFormatCondition styleFormatCondition2 = new DevExpress.XtraGrid.StyleFormatCondition();
        //    gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
        //    styleFormatCondition1.Appearance.BackColor = BojaStorno;
        //    styleFormatCondition1.Appearance.Options.UseBackColor = true;
        //    styleFormatCondition1.ApplyToRow = true;
        //    styleFormatCondition1.Column = gridView1.Columns["IDDokumentTip"];
        //    styleFormatCondition1.Condition = DevExpress.XtraGrid.FormatConditionEnum.Equal;
        //    styleFormatCondition1.Value1 = Storno;
        //    styleFormatCondition2.Appearance.BackColor = System.Drawing.Color.FromArgb(180, ((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
        //    styleFormatCondition2.Appearance.Options.UseBackColor = true;
        //    styleFormatCondition2.ApplyToRow = true;
        //    styleFormatCondition2.Column = gridView1.Columns["IDStatus"];
        //    styleFormatCondition2.Condition = DevExpress.XtraGrid.FormatConditionEnum.Equal;
        //    styleFormatCondition2.Value1 = 0;
        //    gridView1.FormatConditions.AddRange(new DevExpress.XtraGrid.StyleFormatCondition[] {
        //    styleFormatCondition1,
        //    styleFormatCondition2});
        //    gridView1.Appearance.FocusedRow.BackColor = System.Drawing.Color.FromArgb(20, 0, 0, 240);
        //}

    }
}
